package com.example.anjia03_3z.config;


import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * 为Spring Security配置类 更改快速失败属性
 */
@Configuration
@Slf4j
public class ValidationConfiguration {
    public ValidationConfiguration() {log.debug("创建配置类对象：ValidationConfiguration");}

    @Bean
    public Validator validator(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()//开始配置
                .failFast(true)//配置快速失败
                .buildValidatorFactory()//构建Validation工厂
                .getValidator();//从Validation工厂中获取Validator对象
    }
}
